﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Sinacor.Infra.Tools.ServiceRegistration.Data
{
    public class Protocol : ResourceAccess
    {
        #region Methods

        public List<Entity.Protocol> SelectProtocol(Entity.Protocol entity)
        {
            const string TCP = "Tcp";
            const string NAMEDPIPE = "NamedPipe";
            const string HTTP = "Http";

            List<Entity.Protocol> response = null;

            if (entity == null || string.IsNullOrEmpty(entity.ProtocolName) || entity.ProtocolName.Equals(TCP))
            {
                Entity.Protocol p = new Entity.Protocol();
                p.ProtocolName = TCP;

                if(response == null)
                    response = new List<Entity.Protocol>();

                response.Add(p);
            }

            if (entity == null || string.IsNullOrEmpty(entity.ProtocolName) || entity.ProtocolName.Equals(NAMEDPIPE))
            {
                Entity.Protocol p = new Entity.Protocol();
                p.ProtocolName = NAMEDPIPE;

                if (response == null)
                    response = new List<Entity.Protocol>();

                response.Add(p);
            }

            if (entity == null || string.IsNullOrEmpty(entity.ProtocolName) || entity.ProtocolName.Equals(HTTP))
            {
                Entity.Protocol p = new Entity.Protocol();
                p.ProtocolName = HTTP;

                if (response == null)
                    response = new List<Entity.Protocol>();

                response.Add(p);
            }

            return response;
        }

        #endregion
    }
}
